package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Victor;


public class Shooter {
    
    //Motors + Sensors
    private final Victor puncher = new Victor(RobotMap.puncherMotor);
    private final DigitalInput puncherSensor = new DigitalInput(RobotMap.shooterSensor);
    
    //Variables
    private static final double motorExpiration = 0.5;
    private static final int puncherSpeed = -1;
    
    public Shooter() {
        puncher.setSafetyEnabled(true);
        puncher.setExpiration(motorExpiration);
    }

    //if the limit switch on the cam is not pressed, then keep moving it.  
    //When it is pressed, it means that the puncher is cocked, and the puncher motor can stop.  
    public void cockPuncher() {
        if (puncherSensor.get() == false) {
            puncher.set(puncherSpeed);
        }
        else {
            puncher.set(0.0);
        }
    }
    
    //if the puncher is ready, fire it, otherwise, cock puncher first
    public void firePuncher() {
        if(puncherSensor.get() == true) {
            puncher.set(puncherSpeed);
            this.cockPuncher();
        }
        else {
            this.cockPuncher();
        }
    }
}
